﻿

define(function (require) {
    var utility = require('utility/utility.js');

    return Backbone.View.extend({
        //... is a list tag.
        tagName: "li",
        template: _.template($("#li_update").html()),
        events: {
    },

    initialize: function () {
        _.bindAll(this, 'render');
        this.model.bind('change', this.render);
        this.model.view = this;

        var $self = this;
        $(this.el).attr('data-theme', 'c')
                  .addClass('ui-btn ui-btn-icon-right ui-li ui-btn-up-c');

        if (this.model.get('IsRead'))
            $(this.el).find('.title').addClass('is-read');

    },

    render: function () {
        var _model = this.model;
        $(this.el).html(this.template(_model.toJSON()));

        var element = $(this.el)[0];
        var alink = $(element).find('.body').find('.ezlink');
        alink.each(function () {
            //去掉连接中的回车 和 一些 带有空内容的连接
            if (this.firstChild.innerHTML == "<br>" || this.firstChild.innerHTML == "") return;

            if ($(this).attr("href").indexOf('target=action') != -1) {
                $(this).addClass('actionLink');
            }

            $(this).appendTo($(element).find(".action-r"));
        })

        //todo: handle a target

        return this;
    },

    clear: function (e) {

    }
});
});